From b9c3e4c59ad494de64d3fcdd636e77b2c3cde9bb Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 29 Aug 2020 13:37:14 -0600 Subject: [PATCH] add ability to disable map preview in GUI (#635) * add CONFIG option to disable map preview feature. * additional excludes for disabled map preview --- gui/advdlg.cc | 4 ++++ gui/app.pro | 36 +++++++++++++++++++++++++----------- gui/mainwindow.cc | 12 ++++++++++-- 3 files changed, 39 insertions(+), 13 deletions(-) diff --git a/gui/advdlg.cc b/gui/advdlg.cc index 469aa4694..81f52c87e 100644 --- a/gui/advdlg.cc +++ b/gui/advdlg.cc @@ -45,6 +45,10 @@ AdvDlg::AdvDlg(QWidget* parent, #endif // Q_OS_WIN connect(ui_.buttonBox, SIGNAL(accepted()), this, SLOT(acceptClicked())); connect(ui_.buttonBox, SIGNAL(rejected()), this, SLOT(rejectClicked())); + +#ifdef DISABLE_MAPPREVIEW + ui_.previewGmap->hide(); +#endif } void AdvDlg::acceptClicked() diff --git a/gui/app.pro b/gui/app.pro index bf359612a..1e4307ddd 100755 --- a/gui/app.pro +++ b/gui/app.pro @@ -14,11 +14,15 @@ QT += core \ widgets \ xml -qtHaveModule(webenginewidgets) { - QT += webenginewidgets webchannel - DEFINES += HAVE_WEBENGINE +disable-mappreview { + DEFINES += DISABLE_MAPPREVIEW } else { - QT += webkit webkitwidgets + qtHaveModule(webenginewidgets) { + QT += webenginewidgets webchannel + DEFINES += HAVE_WEBENGINE + } else { + QT += webkit webkitwidgets + } } unix:DESTDIR = objects @@ -57,7 +61,9 @@ FORMS += aboutui.ui FORMS += advui.ui FORMS += donate.ui FORMS += filterui.ui -FORMS += gmapui.ui +!disable-mappreview { + FORMS += gmapui.ui +} FORMS += mainwinui.ui FORMS += miscfltui.ui FORMS += preferences.ui @@ -76,13 +82,17 @@ SOURCES += filterdlg.cc SOURCES += filterwidgets.cc SOURCES += format.cc SOURCES += formatload.cc -SOURCES += gmapdlg.cc -SOURCES += gpx.cc +!disable-mappreview{ + SOURCES += gmapdlg.cc + SOURCES += gpx.cc +} SOURCES += help.cc SOURCES += latlng.cc SOURCES += main.cc SOURCES += mainwindow.cc -SOURCES += map.cc +!disable-mappreview{ + SOURCES += map.cc +} SOURCES += optionsdlg.cc SOURCES += preferences.cc SOURCES += processwait.cc @@ -106,11 +116,15 @@ HEADERS += filterdlg.h HEADERS += filterwidgets.h HEADERS += format.h HEADERS += formatload.h -HEADERS += gmapdlg.h -HEADERS += gpx.h +!disable-mappreview { + HEADERS += gmapdlg.h + HEADERS += gpx.h +} HEADERS += help.h HEADERS += mainwindow.h -HEADERS += map.h +!disable-mappreview { + HEADERS += map.h +} HEADERS += optionsdlg.h HEADERS += preferences.h HEADERS += processwait.h diff --git a/gui/mainwindow.cc b/gui/mainwindow.cc index 52bd16b64..83560e180 100644 --- a/gui/mainwindow.cc +++ b/gui/mainwindow.cc @@ -65,7 +65,9 @@ #include "donate.h" // for Donate #include "filterdlg.h" // for FilterDialog #include "formatload.h" // for FormatLoad +#ifndef DISABLE_MAPPREVIEW #include "gmapdlg.h" // for GMapDialog +#endif #include "help.h" // for ShowHelp #include "optionsdlg.h" // for OptionsDlg #include "preferences.h" // for Preferences @@ -886,9 +888,11 @@ bool MainWindow::isOkToGo() return false; } - if (babelData_.outputType_ == BabelData::noType_ && babelData_.previewGmap_) { - } +#ifndef DISABLE_MAPPREVIEW if (babelData_.outputType_ == BabelData::noType_ && !babelData_.previewGmap_) { +#else + if (babelData_.outputType_ == BabelData::noType_) { +#endif QMessageBox::information(nullptr, QString(appName), tr("No valid output specified")); return false; } @@ -1038,6 +1042,7 @@ void MainWindow::applyActionX() formatList_[fidx].bumpWriteUseCount(1); } +#ifndef DISABLE_MAPPREVIEW // Now output for preview in google maps QString tempName; if (babelData_.previewGmap_) { @@ -1055,6 +1060,7 @@ void MainWindow::applyActionX() args << "gpx"; args << "-F" << tempName; } +#endif ui_.outputWindow->clear(); ui_.outputWindow->appendPlainText("gpsbabel " + args.join(" ")); @@ -1068,6 +1074,7 @@ void MainWindow::applyActionX() ui_.outputWindow->appendPlainText(outputString); if (x) { ui_.outputWindow->appendPlainText(tr("Translation successful")); +#ifndef DISABLE_MAPPREVIEW if (babelData_.previewGmap_) { this->hide(); GMapDialog dlg(nullptr, tempName, babelData_.debugLevel_ >=1 ? ui_.outputWindow : nullptr); @@ -1076,6 +1083,7 @@ void MainWindow::applyActionX() QFile(tempName).remove(); this->show(); } +#endif } else { ui_.outputWindow->appendPlainText(tr("Error running gpsbabel: %1\n").arg(errorString)); } -- 2.30.2